package com.alks.pad.controller.last;

import com.alks.common.aop.Idempotent;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.entity.PcLastingQualityCollect;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.pad.commom.date.thread.PadUserIdThread;
import com.alks.pad.data.request.last.LastCollectDetailRequest;
import com.alks.pad.data.request.last.LotNoRequest;
import com.alks.pad.service.last.LastCollectDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/pad/last")
@Api(tags = {"成型投产", "成型产出","成型品质"})
public class LastCollectDetailController {

    @Resource
    private LastCollectDetailService lastCollectDetailService;

    @WebLogger
    @PostMapping("/getLotNos")
    @ApiOperation(value = "选择当日派工指令",tags = "成型投产")
    public ResponseInfo getLotNos(@RequestBody LotNoRequest request){
        return lastCollectDetailService.getLotNos(request);
    }

    @WebLogger
    @GetMapping("/lot/detail")
    @ApiOperation(value = "指令信息",tags = "成型投产")
    public ResponseInfo getLotDetail(@RequestParam String lotNo){
        return lastCollectDetailService.getLotDetail(lotNo);
    }

    @WebLogger
    @PostMapping("/LastCollectDetail")
    @ApiOperation(value = "查询指令投产状况",tags = "成型投产")
    public ResponseInfo LastCollectDetail(@RequestBody LotNoRequest request){
        return lastCollectDetailService.LastCollectDetail(request);
    }

    @WebLogger
    @GetMapping("/todayLastCollectDetail")
    @ApiOperation(value = "当日投产记录",tags = "成型投产")
    public ResponseInfo todayLastCollectDetail(@RequestParam String deptNo){
        return lastCollectDetailService.todayLastCollectDetail(deptNo);
    }

    @WebLogger
    @GetMapping("/todayLastCollectDetailStatus")
    @ApiOperation(value = "当日投产状况",tags = "成型投产")
    public ResponseInfo todayLastCollectDetailStatus (@RequestParam String deptNo){
        return lastCollectDetailService.todayLastCollectDetailStatus(deptNo);
    }

    @WebLogger
    @GetMapping("/hourLastCollectDetailStatus")
    @ApiOperation(value = "小时投产状况",tags = "成型投产")
    public ResponseInfo hourLastCollectDetailStatus (@RequestParam String deptNo){
        return lastCollectDetailService.hourLastCollectDetailStatus(deptNo);
    }

    @WebLogger
    @GetMapping("/unLastCollectDetail")
    @ApiOperation(value = "投产未满明细",tags = "成型投产")
    public ResponseInfo unLastCollectDetail (@RequestParam String deptNo){
        return lastCollectDetailService.unLastCollectDetail(deptNo);
    }

    @WebLogger
    @PostMapping("/add")
    @ApiOperation(value = "点击生产号码",tags = "成型投产")
    @Idempotent(info = "正在处理中,请稍后重试!")
    public ResponseInfo add (@RequestBody LastCollectDetailRequest request){
        return lastCollectDetailService.add(request);
    }

    @WebLogger
    @GetMapping("/SizeByLotNo")
    @ApiOperation(value = "号码明细",tags = "成型投产")
    public ResponseInfo SizeByLotNo (@RequestParam String lotNo){
        String companyId = PadUserIdThread.get().getCompanyId();
        return lastCollectDetailService.SizeByLotNo(companyId, lotNo);
    }

    @WebLogger
    @PostMapping("/delLastCollectDetail")
    @ApiOperation(value = "当日投产记录-删除",tags = "成型投产")
    public ResponseInfo delLastCollectDetail (@RequestBody LastCollectDetailRequest request){
        return lastCollectDetailService.delLastCollectDetail(request);
    }

    @WebLogger
    @PostMapping("/produceAdd")
    @ApiOperation(value = "点击生产号码",tags = "成型产出")
    @Idempotent(info = "正在处理中,请稍后重试!")
    public ResponseInfo produceAdd (@RequestBody LastCollectDetailRequest request){
        return lastCollectDetailService.produceAdd(request);
    }

    @WebLogger
    @PostMapping("/getFrontSectionLotNo")
    @ApiOperation(value = "查询前段投产指令",tags = "成型产出")
    public ResponseInfo getFrontSectionLotNo(@RequestBody LastCollectDetailRequest request){
        return lastCollectDetailService.getFrontSectionLotNo(request);
    }

    @WebLogger
    @PostMapping("/LastCollectDetail2")
    @ApiOperation(value = "查询指令产出状况",tags = "成型产出")
    public ResponseInfo LastCollectDetail2(@RequestBody LotNoRequest request){
        return lastCollectDetailService.LastCollectDetail2(request);
    }

    @WebLogger
    @GetMapping("/hourLastCollectDetail2Status")
    @ApiOperation(value = "小时产出状况",tags = "成型产出")
    public ResponseInfo hourLastCollectDetail2Status (@RequestParam String deptNo){
        return lastCollectDetailService.hourLastCollectDetail2Status(deptNo);
    }

    @WebLogger
    @GetMapping("/todayLastCollectDetail2")
    @ApiOperation(value = "当日产出记录",tags = "成型产出")
    public ResponseInfo todayLastCollectDetail2(@RequestParam String deptNo){
        return lastCollectDetailService.todayLastCollectDetail2(deptNo);
    }

    @WebLogger
    @GetMapping("/todayLastCollectDetail2Status")
    @ApiOperation(value = "当日产出状况",tags = "成型产出")
    public ResponseInfo todayLastCollectDetail2Status (@RequestParam String deptNo){
        return lastCollectDetailService.todayLastCollectDetail2Status(deptNo);
    }

    @WebLogger
    @PostMapping("/delLastCollectDetail2")
    @ApiOperation(value = "当日产出记录-删除",tags = "成型产出")
    public ResponseInfo delLastCollectDetail2 (@RequestBody LastCollectDetailRequest request){
        return lastCollectDetailService.delLastCollectDetail2(request);
    }

    @WebLogger
    @GetMapping("/reasons")
    @ApiOperation(value = "不良原因",tags = "成型品质")
    public ResponseInfo reasons (@RequestParam String deptType){
        return lastCollectDetailService.reasons(deptType);
    }

    @WebLogger
    @GetMapping("/dayAdd")
    @ApiOperation(value = "当日录入记录",tags = "成型品质")
    public ResponseInfo dayAddList (@RequestParam String deptNo){
        return lastCollectDetailService.dayAddList(deptNo);
    }

    @WebLogger
    @GetMapping("/dayQualityStatus")
    @ApiOperation(value = "当日品质状况",tags = "成型品质")
    public ResponseInfo dayQualityStatus (@RequestParam String deptNo){
        return lastCollectDetailService.dayQualityStatus(deptNo);
    }

    @WebLogger
    @GetMapping("/hourQualityStatus")
    @ApiOperation(value = "小时品质状况",tags = "成型品质")
    public ResponseInfo hourQualityStatus (@RequestParam String deptNo){
        return lastCollectDetailService.hourQualityStatus(deptNo);
    }

    @WebLogger
    @PostMapping("/delPcLastingQualityCollect")
    @ApiOperation(value = "当日录入记录-删除",tags = "成型品质")
    public ResponseInfo delPcLastingQualityCollect (@RequestBody PcLastingQualityCollect request){
        return lastCollectDetailService.delPcLastingQualityCollect(request);
    }

    @WebLogger
    @PostMapping("/addPcLastingQualityCollect")
    @ApiOperation(value = "点击添加",tags = "成型品质")
    public ResponseInfo addPcLastingQualityCollect (@RequestBody PcLastingQualityCollect request){
        return lastCollectDetailService.addPcLastingQualityCollect(request);
    }
}
